#include<iostream>
#include<string>
#include<unistd.h>
#include"TcpServer.hpp"
#include"Protocol.hpp"
#include"ServerCalculator.hpp"
#include"Daemon.hpp"

static void Usage(char* args)
{
    std::cout << "\nUsage: " << args << " port\n" << std::endl;
}
int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(0);
    }
    uint16_t port = std::stoi(argv[1]);
    ServerCalculator cal;
    TcpServer *tsvp = new TcpServer(port, std::bind(&ServerCalculator::Calculator, &cal, std::placeholders::_1));
    tsvp->InitServer();
    Daemon();
    //daemon(0,0);
    tsvp->Start();
    return 0;
}